<template>
	<view class="main">
		<view class="ward">
			<u-icon name="arrow-leftward" color="#fff" size="40" @tap="back()"></u-icon>
		</view>
		<view class="user">
			<view class="userL">
				<view class="userL-t">
					收款账户
				</view>
				<view class="userL-b">
					{{shop.shopname}}
				</view>
			</view>
			<view class="userR">
				<image :src="shop.avatar" mode=""></image>
			</view>
		</view>
		<view class="content">
			<view class="contentTitle">
				易货额转账金额
			</view>
			<view class="contentInput">
				<view class="contentInput-l" style="font-weight: 600;">
					e
				</view>
				<view class="contentInput-r">
					<input type="number" v-model="params.money" />
				</view>
			</view>
			<view class="contentText">
				<view class="contentText-item">
					<view class="">
						账户余额：{{userInfo.money}}元
					</view>
					<view class="">
						免手续费：0免手续费
					</view>
				</view>
				<view class="contentText-item" v-if="false">
					限时易货额余额：0限时易货额
				</view>
			</view>
			<view class="contentMoney">
				<view class="contentMoney-l">
					实付金额
				</view>
				<view class="contentMoney-r">
					+<span>{{params.money?params.money:0}}</span>易货额
				</view>
			</view>
			<view class="contentNote">
				<textarea rows="4" cols="50" placeholder="添加转账备注"></textarea>
			</view>
			<view class="contentHit">
				<view class="contentHit-item">
					转账温馨提示：
				</view>
				<view class="contentHit-item">
					1：请认真核对转账手机号或转账地址；

				</view>
				<view class="contentHit-item">

					2：转账完成后相应资产将实时到账，您可以在资产记录里查看详情；
				</view>
			</view>
			<view class="contentPay" @tap="confirmTransfer()">
				支付
			</view>
		</view>
		<view class="box" v-if="isShowPaypass" @tap="this.$wanlshop.to('/pages/user/auth/password');">
			<view class="boxBack"></view>
			<view class="boxContent">
				<view class="boxContent-title">
					提示
				</view>
				<view class="boxContent-text">
					未设置支付密码，是否现在去设置
				</view>
				<view class="boxContent-button">
					确定
				</view>
			</view>
		</view>
	</view>
</template>
<style>
	@import "goodslist";
</style>
<script>
	const app = getApp();
	import jvue from '@/libs/jdk/jvue';
	export default {
		data() {
			return {
				num: 1.0,
				tab: 0,
				query:{},
				shop:{},
				id:0,
				userInfo:{},
				isShowPaypass:false,
				params:{
					money:1.0,//转增余额
					mobile:"",//转增电话
					nickname:'',
					// password:"",
				}
			}
		},
		onLoad(e){
			this.query = e;
			this.id= e.id;
			this.load_entity(this.id);
		},
		onShow(){
			this.loadUserLoginStatus();
		},
		methods: {
			back(){
				jvue.back();
			},
			load_entity(id){
				var that = this;
				uni.showLoading({	title: '加载中...',	mask: false		});				
				var api_url = "/xiangapi/loadshop?id=" + id;
				var url =  api_url ;			
				console.log("商家",url);
				uni.request({
					url: url,
					method: 'GET',
					data: {
						
					},
					success: res => {						
						console.log("load_entity",res);						
						that.shop = res.data;
						this.params.mobile = that.shop.mobile;
						uni.hideLoading();
					},
					fail: () => {},
					complete: () => {}
				});
			},
			async loadUserLoginStatus() {
				await uni.request({
					url: '/wanlshop/user/refresh',
					method: 'POST',
					success: res => {
						this.userInfo=res.data.userinfo;
						//if(this.userInfo.)
						
						this.$store.commit('statistics/edit', res.data.statistics);
						this.$store.commit('user/setUserInfo', res.data.userinfo);
					}
				});
				uni.stopPullDownRefresh();
			},
			pay(){
				var that = this;
				var url = "/city/new_pages/receive";
				jvue.toUrl(url);
			},
			async confirmTransfer(){
				if(!this.params.mobile)  return this.$wanlshop.msg('请输入接收人')
				if(!this.params.money)  return this.$wanlshop.msg('请输入转赠余额')
				await uni.request({
					url: '/wanlshop/Signin/zhuan_money',
					method: 'POST',
					data:this.params,
					success: res => {
						console.log("res",res);
						
						if(res.data==null){
							this.$wanlshop.msg('转增成功')
							setTimeout(()=>{
								uni.navigateBack()
							},1500)
						}
						else{
							console.log("res.data",res.data);
							if(res.data.code==0){
								this.$wanlshop.msg(res.data.msg);
							}
							else{
							
								
							}
						}
					}
				});
			}
		}
		
	}
</script>

<style>
	.main {
		background: #EDEDED;
	}

	.ward {
		
		width: 80rpx;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		position: fixed;
		left: 40rpx;
		top: 50rpx;
		z-index: 999;
		/*
		border: 2rpx solid #fff;
		border-radius: 50%;
		background: rgba(0, 0, 0, .2);*/
	}

	.user {
		padding: 40rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding-top: 120rpx;
	}

	.userL-t {
		font-size: 44rpx;
		font-weight: 600;
	}

	.userL-b {
		font-size: 32rpx;
		margin-top: 10rpx;
	}

	.userR image {
		width: 160rpx;
		height: 160rpx;
		box-shadow: 0 0 10rpx #ccc;
		border-radius: 30rpx;
	}

	.boxBack {
		position: fixed;
		background: rgba(0, 0, 0, .6);
		width: 100%;
		height: 100vh;
		top: 0;
	}

	.boxContent {
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
		margin: auto;
		background: #fff;
		width: 80%;
		height: 300rpx;
		border-radius: 30rpx;
		text-align: center;
	}

	.boxContent-title {
		font-size: 32rpx;
		font-weight: 600;
		margin-top: 50rpx;
	}

	.boxContent-text {
		margin-top: 20rpx;
		color: #86909C;
	}

	.boxContent-button {
		background: #E41F19;
		width: 70%;
		left: 0;
		right: 0;
		margin: auto;
		margin-top: 60rpx;
		color: #fff;
		padding: 14rpx;
		border-radius: 10rpx;
	}

	.content {
		background: #fff;
		border-radius: 40rpx 40rpx 0 0;
		padding: 40rpx;
	}

	.contentInput {
		display: flex;
		align-items: end;
		border-bottom: 2rpx solid #ededed;
		/* 		padding-bottom: 6rpx; */
		font-size: 80rpx;
		  
		 
		
	}

	.contentInput-r input {
		font-size: 60rpx;
		margin-left: 80rpx;
		border: 1px solid #f0971d;
		text-align: right;
	}

	.contentText {
		font-size: 24rpx;
		font-weight: 600;
		margin-top: 30rpx;
	}

	.contentText-item {
		display: flex;
		justify-content: space-between;
		margin-bottom: 10rpx;
	}

	.contentPay {
		background: #FD0304;
		width: 70%;
		position: fixed;
		bottom: 40rpx;
		text-align: center;
		color: #fff;
		border-radius: 60rpx;
		padding: 20rpx;
		left: 0;
		right: 0;
		margin: auto;
	}

	.contentMoney {
		border: 2rpx solid #ededed;
		border-radius: 10rpx;
		padding: 30rpx 20rpx;
		display: flex;
		margin-top: 30rpx;
		justify-content: space-between;
		align-items: center;
	}

	.contentMoney-l {
		font-weight: 600;
		font-size: 32rpx
	}

	.contentMoney-r {
		font-size: 24rpx
	}

	.contentMoney-r span {
		color: #E41F19;
		font-weight: 600;
		font-size: 32rpx;
		margin: 0 4rpx;
		margin-right: 10rpx;
	}

	.contentNote {
		margin-top: 30rpx;
	}

	.contentHit {
		margin-top: 30rpx;
	}
</style>